/*******************************************************************************
 * *
 * *             COPYRIGHT 2012 CLEARLEAP, INC. ALL RIGHTS RESERVED.
 * *             CLEARLEAP CONFIDENTIAL PROPRIETARY
 * *             TEMPLATE VERSION R01.00
 * *
 * ********************************************************************************
 * *
 * *  FILE NAME: HardcodedNamespaceResolver.java
 * *
 * *---------------------------------- PURPOSE ------------------------------------
 * *
 * * XML Namespace resolution for Signing XML feature
 * *
 * *
 * *----------------------------- REVISION HISTORY --------------------------------
 * *
 * * Date      ID        Tracking#      Description
 * * --------  --------  -------------  -------------------------------------------
 * * 01.07                              Created
 * *
 * *--------------------------- INCLUDES ----------------------------*
 * *
 ******************************************************************************/
package com.easysale.util;

import java.util.Iterator;

import javax.xml.XMLConstants;
import javax.xml.namespace.NamespaceContext;

public class HardcodedNamespaceResolver implements NamespaceContext {
    /**
     * This method returns the uri for all prefixes needed. Whereever possible
     * it uses XMLConstants.
     *
     * @param prefix
     * @return uri
     */
    public String getNamespaceURI(String prefix) {
        String result;
        if (prefix == null) {
            throw new IllegalArgumentException("No prefix provided!");
        } else if (prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
            result = "";
        } else if (prefix.equals("soap11")) {
            result = "http://www.w3.org/2001/12/soap-envelope";
        } else if (prefix.equals("xacml-samlp")) {
            result = "urn:oasis:names:tc:xacml:2.0:profile:saml2.0:v2:schema:protocol";
        } else if (prefix.equals("saml")) {
            result = "urn:oasis:names:tc:SAML:2.0:assertion";
        } else if (prefix.equals("xacml-context")) {
            result = "urn:oasis:names:tc:xacml:2.0:context:schema:os";
        } else {
            result = XMLConstants.NULL_NS_URI;
        }
        return result;
    }

    public String getPrefix(String namespaceURI) {
        // Not needed in this context.
        return null;
    }

    public Iterator getPrefixes(String namespaceURI) {
        // Not needed in this context.
        return null;
    }
}
